/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;

import DTO.DatVeDTO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author Tu Nguyen
 */
public class DatVeDAO {
    public static boolean Them(DatVeDTO dv)
    {
       String x="";
         try {
            Connection conn = DBConnect.Connect();
            Statement statement = conn.createStatement();
      
            String sql = "Insert into "
                    + "dat_ve(id, cmnd, chuyen, ga_di, ga_den, ghe, loai_ghe, so_luong, tong_tien, doi_tuong, ngay_tao, tinh_trang) "
                    + "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
                
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1, dv.id);
            ps.setString(2, dv.cmnd);
            ps.setString(3, dv.chuyen);
            ps.setInt(4, dv.ga_di);
            ps.setInt(5, dv.ga_den);
            ps.setString(6, dv.ghe);
            ps.setString(7, dv.loai_ghe);
            ps.setInt(8, 1);
            ps.setFloat(9, dv.giave);
            ps.setInt(10, dv.doi_tuong);
            ps.setString(11, dv.ngaydat);
            ps.setString(12, dv.tinh_trang);
            x=ps.toString();
            int n = ps.executeUpdate();
            conn.close();
            return true;
           // JOptionPane.showMessageDialog(null, "Thêm thành công!!!", "Thông báo", 1);
        } catch (Exception ex) {
           System.out.println(ex);
        }
        return false;
    }
}
